import 'package:flutter/material.dart';

class MainCheckboxPage extends StatefulWidget {
  @override
  _MainCheckboxPageState createState() => _MainCheckboxPageState();
}

class _MainCheckboxPageState extends State<MainCheckboxPage> {
  bool status = false;
  bool statusa = false;
  bool statusb = false;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text('CheckBox'),
        ),
        body: Column(
          children: <Widget>[
            Container(
              height: 100,
              margin: EdgeInsets.all(12),
              padding: EdgeInsets.all(20),
              color: Colors.grey[400],
              child: Row(
                children: <Widget>[
                  Checkbox(
                    value: status,
                    onChanged: (value) {
                      setState(() {
                        status = value;
                      });
                    },
                    activeColor: Colors.red,
                  ),
                  Text('请同意用户协议')
                ],
              ),
            ),
            Container(
              height: 100,
              margin: EdgeInsets.all(12),
              padding: EdgeInsets.all(20),
              color: Colors.grey[400],
              child: CheckboxListTile(
                secondary: Image.asset('images/2.0/logo.jpg'),
                title: Text('这是一级标题'),
                subtitle: Text('这是二级标题'),
                value: statusa,
                onChanged: (value) {
                  setState(() {
                    statusa = value;
                  });
                },
              ),
            ),
            Container(
              height: 100,
              color: Colors.grey[400],
              child: InkWell(
                child: Container(
                  padding: EdgeInsets.all(20),
                  child: Row(
                    children: <Widget>[
                      Image.asset(
                          statusb
                              ? 'images/3.0/selected.jpg'
                              : 'images/3.0/unselected.jpg',
                          width: 50,
                          height: 50),
                      SizedBox(width: 50),
                      Text('请同意用户协议')
                    ],
                  ),
                ),
                onTap: () {
                  setState(() {
                    statusb = !statusb;
                  });
                },
              ),
            ),
          ],
        ));
  }
}
